package com.hfh.jdbc;



import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.hfh.jdbc.DBUtils;
/**
 * @Author hfh
 * @Date 2022 09 19 20 59
 **/
public class JDBCTest2 {
    public static void main(String[] args) {
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            con = DBUtils.getConnection();
            String sql = "select * from scores where id = ?";
            ps = con.prepareStatement(sql);
            ps.setString(1,"3");

            ps.addBatch();
            ps.executeBatch();
            rs = ps.executeQuery();
            while (rs.next()){
                System.out.println(rs.getString(1));
                System.out.println(rs.getString(2));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            DBUtils.close(con,ps,rs);
        }
    }
}
